#include <iostream>
using namespace std;

class Person {
  public:
    Person() {
      cout << "无参构造" << endl; 
    }

    Person(const char*name) {
      cout << "只有一个参数的有参构造" << endl;
      strcpy(this->name, name);
    }
    Person(const char *name, int age) {
      cout << "有参构造" << endl;
      strcpy(this->name, name);
      this->age = age;
    }
    Person(const Person &p) {
      cout << "Copy 构造" << endl;
      strcpy(name, p.name);
      age = p.age;
    }

    int age;
    char name[12];
    void print() {
      cout << "name: " << name << " age: " << age << endl;
    }
};

int main() {
  // 使用有参构造
  // 方式一
  Person p3("Mango2", 18);
  p3.print();

  // 方式二，C++11
  Person p4 = {"Mango4", 18};
  p4.print();

  // 方式三，C++11
  Person p5{"Mango5", 20};
  p5.print();

  // 方式四
  Person p6 = Person("Mango6", 18);
  p6.print();

  // 方式五，不推荐
  Person p7 = ("Mango7");
  p7.print();

  return 0;
}
